<template>
	<el-dialog v-model="visible" :destroy-on-close="true" :width="540" top="5" :title="`${dialogData.title}日志配置`">
		<el-form ref="ruleFormRef" :rules="rules" :disabled="dialogData.isView" :model="formData" label-width="100px">
			<el-row>
				<el-col :span="24">
					<el-form-item label="数据来源" prop="dataSource" clearable>
						<el-input v-model="formData!.dataSource" placeholder="请输入数据来源"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="字段名" prop="columnKey" clearable>
						<el-input v-model="formData!.columnKey" placeholder="请输字段名"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="字段名称" prop="columnName" clearable>
						<el-input v-model="formData!.columnName" placeholder="请输入字段名称"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="字典编码" prop="dictCode" clearable>
						<el-space fill>
							<el-input v-model="formData!.dictCode" placeholder="请输入字典编码"></el-input>
							<p>如果该值Label需从数据字典获取，则需要填入字典值</p>
						</el-space>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="字典来源" prop="dictSource" clearable>
						<el-select v-model="formData.dictSource">
							<el-option :value="0" label="直接取值"></el-option>
							<el-option :value="1" label="其他字段取值"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<template #footer>
			<el-button @click="visible = false">取消</el-button>
			<el-button type="primary" v-show="!dialogData.isView" @click="handleSubmit">确定</el-button>
		</template>
	</el-dialog>
</template>

<script setup lang="ts" name="UserDialog">
import { ref, reactive } from 'vue';
import { ElMessage, FormInstance, FormRules, ElMessageBox } from 'element-plus';
import { Plus, Upload } from '@element-plus/icons-vue';
import { useModal } from '/@/hooks/useModal';
import rulesObj from './rules';

const formData = reactive<any>({
	dataSource: '',
	columnKey: '',
	columnName: '',
	dictCode: '',
	dictSource: 0,
	dataStatus: 1
});

//验证规则
const rules = reactive<FormRules>(rulesObj);

const ruleFormRef = ref<FormInstance>();
const { visible, acceptParams, handleSubmit, dialogData } = useModal(formData, ruleFormRef)

defineExpose({
	acceptParams,
});
</script>
